<%@ include file="/header.jsp" %>

<h1>Add new Band</h1>

<form:form commandName="band">

    <p><label for="title">Title</label><br/>
    <form:input path="title"/>
    <form:errors path="title" cssStyle="color: red"/>
    </p>

    <p><label for="foundationDate">Foundation Date</label><br/>
    <form:input path="foundationDate"/>
    <form:errors path="foundationDate" cssStyle="color: red" />
    </p>
	
    <p><label for="members">Band's members</label><br/>
    <form:select path="members">
    	<form:options items="${people}" itemValue="id" itemLabel="surname" />
    </form:select>
    <form:errors path="members" cssStyle="color: red"/>
    </p>
    
    <p><label for="person">Genres</label><br/>
    <form:select path="genres">
    	<form:options items="${genres}" itemValue="id" itemLabel="name" />
    </form:select>
    <form:errors path="genres" cssStyle="color: red"/>
    </p>
    
    
	<c:choose>
	<c:when test="${band.updateGranted}">
	<p><input type="submit" value="Save"/></p>
	</c:when>
	<c:otherwise>
	<p>Edit Not allowed</p>
	</c:otherwise>
	</c:choose>       
</form:form>
	
	<p>Band's Member info</p>
	<table border="1" width="90%" cellspacing="0" style="margin:10px">
		<tr>
			<td>Id</td>
			<td>
			Name
			</td>
			<td>
			Surname
			</td>
		</tr>
		<c:forEach items="${band.members}" var="item">                
		<tr>
		<td><a href="/lab02-music-portal/music/add_person?id=${item.id}"> <c:out value="${item.id}"/></a></td>
		<td><c:out value="${item.name}"/></td>
		<td><c:out value="${item.surname}"/></td>
		</tr>
		</c:forEach>
	</table> 
	
	<p>Band's Genre info</p>
	<table border="1" width="90%" cellspacing="0" style="margin:10px">
		<c:forEach items="${band.genres}" var="item">                
		<tr>
		<td><c:out value="${item.name}"/></td>
		</tr>
		</c:forEach>
	</table> 
    
	<p>Band's Album info</p>
	<table border="1" width="90%" cellspacing="0" style="margin:10px">
		<tr>
			<td>Id</td>
			<td>
			Title
			</td>
			<td>
			Year
			</td>			
		</tr>
		<c:forEach items="${band.albums}" var="item">                
		<tr>
		<td><a href="/lab02-music-portal/music/add_album?id=${item.id}"> <c:out value="${item.id}"/></a></td>
		<td><c:out value="${item.title}"/></td>
		<td><c:out value="${item.year}"/></td>
		</tr>
		</c:forEach>
	</table>  

<%@ include file="/footer.jsp" %>

